package com.exception;

import com.vo.Result;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

@RestControllerAdvice   //TODO：标记为异常处理类
public class ProjectExceptionAdvice {

    //TODO：处理系统异常
    @ExceptionHandler(SystemException.class)
    public Result doSystemException(SystemException se) {
        return new Result(se.getCode(),se.getMessage(),null);
    }

    //TODO：处理业务异常
    @ExceptionHandler(BusinessException.class)
    public Result doBusinessException(BusinessException be) {
        return new Result(be.getCode(),be.getMessage(),null);
    }

    //TODO：处理其它未知异常
    @ExceptionHandler
    public Result doOtherException(Exception e) {
        return new Result(000,"未知异常",null);
    }
}
